<template>
    <div class="app-container">
        <!-- 查询模块 -->
        <div class="formDiv">
            <el-form ref="form" :inline="true" :model="form" label-width="130px">
                <el-row>
                    <el-col :span="6">
                        <el-form-item label="流水单号">
                            <el-input v-model="form.realName"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="姓名">
                            <el-input v-model="form.username"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="手机号">
                            <el-input v-model="form.identity"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="提交时间" width="236">
                            <el-date-picker
                                value-format="yyyy-MM-dd HH:mm:ss"
                                v-model="dates"
                                type="daterange"
                                range-separator="-"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item>
                            <el-button style="margin-left:60px" type="primary" @click="searchFn">查询</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <!-- 主页列表 -->
        <div class="listDiv" v-loading="tableLoading">
            <!-- table列表 -->
            <el-table
                :data="tableData"
                style="width: 100%">
                <el-table-column
                    prop="realname"
                    label="流水单号"
                >
                </el-table-column>
                <el-table-column
                    prop="telephone"
                    label="客户姓名"
                >
                </el-table-column>
                <el-table-column
                    prop="identity"
                    label="客户手机号"
                >
                </el-table-column>
                <el-table-column
                    prop="createdAt"
                    label="修改前金额"
                >
                </el-table-column>
                <el-table-column
                    prop="identity"
                    label="修改后金额"
                >
                </el-table-column>
                <el-table-column
                    prop="identity"
                    label="修改金额"
                >
                </el-table-column>
                <el-table-column
                    prop="identity"
                    label="修改时间"
                >
                </el-table-column>
            </el-table>
            <!-- 分页 -->
            <div class="pagesCon">
                <div>
                    <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="listForm.pageNum"
                    :page-sizes="page_sizes"
                    :page-size="listForm.limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="page_totals">
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { certificationList,certificationListDelete } from '@/api/certificationList'

export default {
    name:"runWaterMoneyIndex",
    data(){
        return{
            val:"1",
            dates:"",
            tableLoading:true,
            form:{
                pageNum:1,
                pageSize:10,
                realName:"",
                username:"",
                identity:""
            },
            tableData: [],
            page_sizes:[10,30,50,100],
            page_totals:60,
            listForm:{
                pageNum:1,
                pageSize:10,
            },
        }
    },
    filters:{
        cardType: function(e){
            return window.helper.cardType(String(e))
        },
    },
    mounted(){
        this.getList(this.listForm)
    },
    methods:{
        //成功状态弹窗
        succStatus(txt){
            this.$message({
                message: txt+'成功',
                type: 'success'
            });
        },
        //失败状态弹窗
        errorStatus(txt){
            this.$message.error(txt+'失败');
        },
        //查询
        searchFn(){
            // console.log(this.form)
            this.getList(this.form)
        },
        //列表数据获取
        getList(e){
            this.tableLoading = true
            let datas = e
            certificationList(datas).then(res => {
                if(!res.data.code){
                    // console.log(res)
                    this.tableData = res.data.data.list
                    this.page_totals = res.data.data.count
                }else{
                    this.$message.error("数据接口访问失败");
                }
                this.tableLoading = false
            })
            .catch(error =>{
                this.$message.error(error);
            })
        },
        // 路由跳转
        toRoutes(e,userId) {
            let route = {name:e,query:{userId:userId}}
            this.$router.push(route)
        },
        //改变页面条数
        handleSizeChange(val) {
            this.form.pageSize = val
            this.getList(this.form)
        },
        //选择页数
        handleCurrentChange(val) {
            this.form.pageNum = val
            this.getList(this.form)
        },
        // 删除
        deleteList(e){
            let datas = {userId:e}
            console.log(datas)
            this.$confirm('删除该条数据, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                console.log(datas)
                certificationListDelete(datas).then(res =>{
                    if(!res.data.code){
                        this.succStatus("删除")
                        this.getList(this.form)
                    }else{
                        this.$message.error(res.data.msg);
                    }
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });          
            });
        }
    }
}
</script>
<style scoped>
/* 分页 */
.pagesCon{height: 40px;margin-top: 20px}
.pagesCon>div{float: right;}
</style>
